
<template>
	<!-- 添加弹框 -->
	<el-dialog title="" size='tiny' :visible.sync="dialogTableVisible" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
	    <div class="bt">老师请假添加管理</div>
	       <el-form label-width="100px" class="form">
		<el-form-item label="开始时间">
				<el-date-picker  v-model="vbtime"  type="date" class="select-block" placeholder="选择日期" @keyup.enter.native="search">  </el-date-picker>
		</el-form-item>

		<el-form-item label="结束时间">
				<el-date-picker  v-model="vetime"  type="date" class="select-block" placeholder="选择日期" @keyup.enter.native="search">  </el-date-picker>
		</el-form-item>
		 <el-form-item label="原因">
 				<el-input v-model="vyy" type="textarea" :rows="3" placeholder="请输入备注" class="select-block"></el-input>
 		</el-form-item>
		</el-form>
		<el-button type="info" class="submit" @click="submit">保存</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data() {
			return {
				vbtime: '',
				vetime: '',
				vyy: '',
				dialogTableVisible: true
			}
		},
		methods: {

			submit() {
				 if(this.vbtime){
          var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
          var time2 = this.$.getLocalTimeNo0(Date.parse(this.vetime));
        }else{
          var time1 = this.vbtime
          var time2 = this.vetime
        }
				//检测
				this.$store.state.loading = true;
			   /* if(!this.mc) {
					this.$message.warning('请填写分类名称');
					this.$store.state.loading = false;
					return;
				} */
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					  btime: time1,
                      etime: time2,
					yy: this.vyy+'',
					yhid: logininfo.id+'',
					xxid:logininfo.xxid+''
				});
				//执行
				this.axios.post(this.$store.state.api + 'lsqj/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
					        this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.bt{
		position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.input {
			display: inline-block;
		}
		.select-block {
	 		display: block;
	 		width: 85%;
 	    }
 	    .form {
		text-align: center;
	}
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
			margin-top: 20px;
		}
	}
</style>
